package duoxiancheng;

import java.util.ArrayList;
import java.util.List;

/**
 * 线程不安全：操作容器
 */
public class UnSafeTest03 implements Runnable{
    static List<String> list = new ArrayList<>();
    @Override
    public void run() {
        list.add(Thread.currentThread().getName());
    }

    public static void main(String[] args) {
        UnSafeTest03 t = new UnSafeTest03();
        for (int i = 0; i <10000 ; i++) {
            new Thread(t).start();
        }
       System.out.println(list.size());
    }
}

